package ds;

public class MyQueue {
    private static class Node {
        Object value;
        Node next;
        Node(Object value) { this.value = value; }
    }
    private Node head, tail;
    public void offer(Object value) {
        Node node = new Node(value);
        if (tail == null) {
            head = tail = node;
        } else {
            tail.next = node;
            tail = node;
        }
    }
    public Object poll() {
        if (head == null) return null;
        Object val = head.value;
        head = head.next;
        if (head == null) tail = null;
        return val;
    }
    public boolean isEmpty() { return head == null; }
} 